<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改密码</title>
<%@ include file="/common/util.jsp"%>


<script type="text/javascript">
var obj = {
	passwordVali : false,
	oldpasswordVali : false,
	passwordCheck :function(){
		if($("#password").val() == $("#cpassword").val()){	
			$("#cpasswordError").css("display","none");
			obj.passwordVali = true;
		}else{
			$("#cpasswordError").html("密码不一致！");
			$("#cpasswordError").css("display","block");
			obj.passwordVali = false;
		}
	},
	oldpasswordCheck : function(){
		
		$.ajax({
			type : "POST",
			contentType : "application/json",
			url : "oldPasswordVali.shtml",
			data : $("#oldpassword").val(),
			dataType : "json",
			success: function(data){
				if(data.oldPasswordFlag == true){
					obj.oldpasswordVali = true;
					$("#oldpasswordError").css("display","none");
				}else{
					obj.oldpasswordVali = false;
					$("#oldpasswordError").html("旧密码不正确！");
					$("#oldpasswordError").css("display","block");
				}
			},
			error: function(){
				dialog_alert("error");
			}
		});
	},
	
	changepassword : function(){
		if(obj.passwordVali == false || obj.oldpasswordVali == false){
			dialog_alert("请正确填写表单！");
			return;
		}
		$.ajax({
			type : "POST",
			contentType : "application/json",
			url : "updatePassword.shtml",
			data : $("#password").val(),
			dataType : "json",
			success: function(data){
				if(data.flag == true){
					dialog_alert("修改成功！");
				}else{
					dialog_alert("修改失败！");
				}
			},
			error: function(){
				dialog_alert("error");
			}
		});
	}
	
};

$(document).ready(function(){
	for ( var i = 1; i < 12; i++) {
        $("#id" + i).removeClass("current");
    }
    $("#id2").addClass("current");

});
</script>
</head>
<body class="main">
	<div class="-frame -style -luster" id="css_container">
		<!--首页框架页眉部分↓-->
		<%@ include file="/WEB-INF/pages/inc/header.jsp"%>
		<!--首页框架页眉部分↑-->

		<div class="content">

			<!-- Left导航菜单◎开始 -->
			<%@ include file="/WEB-INF/pages/inc/leftmenu.jsp"%>
			<!-- Left导航菜单◎结束 -->

			<div class="main-mid">
				
				<div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a href="#">修改密码</a></div>
				<div class="css_contentDiv">
					<div class="searchDetailed  c-border-radius  b-box-shadow">
					
						  <table align="center" width="600" border="0" cellspacing="0" cellpadding="0">
						  	 <tr>
             				 	 <td width="91" height="36" class="mainText"><label class="formlabel"><font color="red">*</font>原始密码：</label></td>
             				 	 <td>
             				 	 <input type="password" class="form_input large"  id="oldpassword" onchange="obj.oldpasswordCheck()"/>
             				 	 </td><td align="left">
             				 	 <div id="oldpasswordError" style="display: none;color:red"></div>
             				 	 </td>
             				 </tr>
             				 <form id="addElecPriceForm" method="post">
             				 <tr>
             				 	 <td width="91" height="36" class="mainText"><label class="formlabel"><font color="red">*</font>新密码：</label></td>
             				 	 <td>
             				 	 <input type="password" class="form_input large"  id="password" onchange="obj.passwordCheck()" />
             				 	 </td>
             				 </tr>
             				 </form>
             				 <tr id="cpasswordDiv">
             				 	 <td width="91" height="36" class="mainText"> <label class="formlabel"><font color="red">*</font>确认密码：</label></td>
             				 	 <td>
             				 	 <input type="password" class="form_input large"  id="cpassword"  onchange="obj.passwordCheck()"/>
		                 	  </td><td align="left">
		                 	  <div id="cpasswordError" style="display: none;color:red"></div>
             				 	 </td>
             				 </tr>
             				 <tr>
             				 	<td height="20"></td>
             				 </tr>
             				 
             				 <tr >
             				 	<td ></td>
						         <td >
						          <input type="button" class="form_save" value="保&nbsp;存" onclick="obj.changepassword()"/>
				              	</td>
             				 
             				 </tr>
             				</table>
              		
              		</div>
				</div>
			</div>

		</div>

		<!--首页框架页尾部分↓-->
		<%@ include file="/WEB-INF/pages/inc/footer.jsp"%>
		<!--首页框架页尾部分↑-->
	</div>
</body>
</html>